package com.hyb.algorithm.data.struct.dp;

/**
 * @Author: huyanbing
 * @Date: 2021/8/12 2:55 下午
 */
public class Fib {

    public static void main(String[] args) {

        Fib fib = new Fib();
        System.out.println(fib.fib(10));
    }


    public int fib(int n) {

        if (n <= 2) {
            return 1;
        }
        int[] mem = new int[n];

        mem[1] = 1;
        mem[2] = 2;

        for (int i = 3; i < n; i++) {
            mem[i] = mem[i - 2] + mem[i - 1];
        }

        return mem[n-1];
    }
}
